<?php
    include_once("../inc/login_controll.inc.php");
	include_once("../class/config.class.php"); 
	$config = config::getConfig();
	include_once($config->getValue("home_path")."/inc/defines.inc.php");

	include_once(HOME_PATH."/class/form.class.php");
	include_once(HOME_PATH."/class/database.class.php");
		
	$oForm = new form($config);
	$oDB = new database($config);
	$oForm->setDB($oDB);
		
	if(isset($_POST['save']) && trim($_POST['save'])=="true"){
		//Neues Formular in der Datenbank anlegen 
		$iId = $oForm->createForm($_POST['name'], $_SESSION['user_id'], $_POST['desc']);
		if(trim($_POST['countStudent'])!=="" && is_numeric($_POST[countStudent])){
			$sClass = (trim($_POST['class'])!=""?$_POST['class']:"");
			$oForm->getToken((int)$_POST['countStudent'], $iId, $sClass);
		}
		header("location:new_quest.php?form=".$iId);		
	}else{
		include(HOME_PATH."/templates/header.tpl.php");
		include(HOME_PATH."/templates/admin/new_form.tpl.php");
		include(HOME_PATH."/templates/footer.tpl.php");
	}
?>
		